import instance from '@/http/index.js'
import type { bindFileAndUserForm,updateDownloadForm,deleteFileForm } from './type.ts'

//统一管理接口
enum API {
    bindFileAndUser_url = '/file/bindFileAndUser',
    updateDownload_url = '/file/updateDownload',
    downloadFile_url = '/file/downloadFile',
    fileList_url = '/file/fileList',
    returnFilesListData_url = '/file/returnFilesListData',
    searchFile_url = '/file/searchFile',
    deleteFile_url = '/file/deleteFile'
}
// 绑定上传者
export const bindFileAndUser = (data:bindFileAndUserForm) => {
    return instance.post(API.bindFileAndUser_url,data)
}
// 更新下载量
export const updateDownload = (data:updateDownloadForm) => {
    return instance.post(API.updateDownload_url,data)
}
// 下载文件
export const downloadFile = (id:number) => {
    return instance.post(API.downloadFile_url,{id})
}
// 获取文件列表
export const fileList = () => {
    return instance.post(API.fileList_url)
}
// 获取文件列表总数
export const fileListLength = () => {
    return instance.post(API.returnFilesListData_url)
}
// 监听换页返回数据 文件列表
export const returnFilesListData = (pager:number) => {
    return instance.post(API.returnFilesListData_url,{pager})
}
// searchFile
export const searchFile = (file_name:string) => {
    return instance.post(API.searchFile_url,{file_name})
}
// 删除文件
export const deleteFile = (data:deleteFileForm) => {
    return instance.post(API.deleteFile_url,data)
}